#include <bits/stdc++.h>
using namespace std;

int a, b, x, y;
void init();
int main() {
    cin >> a >> b >> x >> y;
    init();
    cout << min(b - a, abs(a - x) + abs(b - y));
    return 0;
}

void init() {
    int mn, mx;
    mn = min(a, b), mx = max(x, y);
    b = a + b - mn; a = mn;
    x = x + y - mx; y = mx;
}